#第九章  穿越网页表单与登录窗口进行采集

import requests

params = {'firstname':"kfz",'lastname':"hui"}
url = "http://pythonscraping.com/files/processing.php"
r = requests.post(url,data=params)
print(r.text)

params = {"username":"kfz","password":"password"}
url = "http://pythonscraping.com/pages/cookies/welcome.php"
r = requests.post(url,data=params) #发送登录参数
print("cookie is set to:")
print(r.cookies.get_dict()) #返回的数据中获取cookie
print("--------------")
r = requests.get("http://pythonscraping.com/pages/cookies/profile.php",cookies=r.cookies) #获取数据的时候把cookie传过去
print("---",r.text)

#Http的基本接入认证
from requests.auth import AuthBase,HTTPBasicAuth
auth = HTTPBasicAuth('kfz','password')
r = requests.post(url="http://pythonscraping.com/pages/auth/login.php",auth=auth)
print("接入http认证后的内容",r.text)
